package com.ziven.common.widget.value;

import android.view.View;

import androidx.annotation.NonNull;

import com.ziven.common.widget.WidgetUtils;
import com.ziven.common.widget.title.TitleView;
import com.ziven.easygo.util.ResourceUtils;
import com.ziven.easygo.util.ViewHelper;

/**
 * @author Ziven
 */
public final class TitleMarginNav extends Value {

    public static TitleMarginNav marginId(int marginId) {
        return margin(ResourceUtils.getDimen(marginId));
    }

    public static TitleMarginNav margin(String margin) {
        return margin(WidgetUtils.dimenInt(margin));
    }

    public static TitleMarginNav margin(int margin) {
        return new TitleMarginNav().accept(my -> {
            my.resId = margin;
        });
    }

    private TitleMarginNav() {}

    @Override
    protected void takeEffect(@NonNull ViewHelper<? extends View> helper) {
        if(helper.getView() instanceof TitleView) {
            ((TitleView) helper.getView()).setContentInsetStartWithNavigation(resId);
        }
    }
}
